<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('供应商资料列表')" />
</head>
<body>
<form>
	<div class="layuiadmin-header-box">
		<th:block th:include="listinclude :: searchTop" />
	</div>
</form>
<div class="mid-content">
    <table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
</div>
<script type="text/html" id="barDh">
	<a class="layui-btn layui-btn-xs dhicon dh-edit" onclick="newTab('/crm/provider/edit?gprovide={{d.gprovide}}','供应商资料({{d.gprovide}}) - 修改')" shiro:hasPermission="crm:provider:edit">&nbsp;编辑</a>
	<a class="layui-btn layui-btn-warm layui-btn-xs dhicon dh-reply" onclick="recover('{{d.gprovide}}')"  shiro:hasPermission="crm:provider:edit">&nbsp;恢复</a>
</script>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = ctx + "crm/provider";
	var gridColumns = [[${gridColumns}]];
	var moduleTable=[[${moduleTable}]];
	/*]]>*/
</script>
<script type="text/javascript">
var $,layer,form,table,wherestr={};
layui.use(['table','form','layer','jquery'], function () {
     $ = layui.$,layer = layui.layer,form = layui.form,table = layui.table;
     $.tablelist.init({
         elem: '#dhtable'
         ,url: prefix + '/list?deleted=1'
         ,totalRow: gridColumns.totalRow
		 ,cols: [gridColumns.gridBody
  		]
        ,toolbar: '#toolbar'
   		,defaultToolbar: [{title:'列设置',layEvent: 'fieldSet',icon: 'layui-icon-set'}] //这里在右边显示
        ,height:'full-90'
     });
	//监听排序事件 
     table.on('sort(ftable)', function(obj){
     	$.tablelist.sort('dhtable',obj);
     });
 	//搜索按钮
  	$('#btn-search').on('click', function () {
		$.each(wherestr,function(i,v){$("#"+i).val()?wherestr[i]=$("#"+i).val():wherestr[i]='';});//动态获取条件的值
		table.reload('dhtable', {page: {curr: 1},where:wherestr});
	});
  	//监听下拉框——添加条件
  	form.on('select(fft)', function(obj){
  		addMore(this);
  	});
});
//打开新标签
function newTab(url,title){
	if(top.layui.index)top.layui.index.openTabsPage(url,title);
	else window.open(url);
}
//通过gprovide彻底删除
function remove(gprovide){
	$.operate.remove("该删除无法恢复，请确认？",prefix + "/delete/",{'providerInfoItems':JSON.stringify([{'gprovide':gprovide}])},function(result){
		$.operate.post(prefix + "/deleteshared", {'gprovide':gprovide});//删除对应共享资料
		allReload(result)
	});
}
//通过guid恢复
function recover(gprovide){
	$.operate.remove("确定要恢复么？",prefix + "/editpost",{'providerInfoItems':JSON.stringify([{'gprovide':gprovide,'deleted':0}])},function(result){
		allReload(result)
	});
}
//刷新
function allReload(result){
    if(result.code==0){
        setTimeout(function(){
            layer.closeAll();
            table.reload('dhtable');
        }, 1000);
    }
}
 </script>
</body>
</html>